#ifndef XGE_GRAPHICS_G_RENDERTARGET_H_
#define XGE_GRAPHICS_G_RENDERTARGET_H_
#include "xge_common_config.h"
#include "xallocator.h"

#include "g_texture.h"
#include "g_colors.h"

namespace xge{
namespace graphics{

  class RenderTexture;
  // A render target is canvas , which we can draw stuff
  // on that target .Typically , a window is a render target,
  // On dx , we can handle many render target which may be
  // off-screen .
  class RenderTarget : public xge::Allocator {
  public:
    // Specifying the texture of this render target.
    // In our game engine, the render target can be
    // 1. The window ( the specific class will be 
    // customized ).
    // 2. Off-screen texture , which is usually used .
    // Rendering the stuff onto a texture .The texture
    // will return a corresponding texture of that 
    // target .And you can do anything for this texture
    // as you wish for common texture .
    RenderTexture* GetTexture() const {
      return texture_;
    }
  public:
    size_t width() const {
      return width_;
    }
    size_t height() const {
      return height_;
    }

  protected:
    RenderTarget( size_t width , size_t height ,
      RenderTexture* texture) 
      : width_(width) , height_(height) , texture_(texture)  {}
    ~RenderTarget(){}
  private:
    // A customized render texture
    size_t width_ , height_;
    RenderTexture* texture_; 
    
  };


  class RenderTexture : public Texture {
  public:
    // by defaul the render texture can not be locked
    // Since DirectX-9.0 , it can be locked (download)
    // we just keep the texture not lockable
    virtual ColorStream Lock( LockOption usage , const Rect& rect ) {
      DUMMY_ARG(usage);
      DUMMY_ARG(rect);
      return ColorStream();
    }
    virtual bool Unlock() {
      return false;
    }
  protected:
    // The derived ctor
    RenderTexture( size_t width , size_t height ) :
           Texture( width , height , width , height ) {}
    ~RenderTexture(){}
  };




}//namespace graphics
}//namespace xge


#endif// XGE_GRAPHICS_G_RENDERTARGET_H_